package cn.mickey.cloud.config;

import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


//@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    /**
     * 将拦截器实列交给spring管理
     * @return
     */
    @Bean
    public LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] releasePath =
                {
                        "/front/**",
                        "/user/login",
                        "/user/register",
                        "user/userLoginVerify",
                        "/**/*.html",
                        "/randomCode",
                        "/"
                };

       /* registry.addInterceptor(loginInterceptor())//添加拦截器功能的实例对象
                .addPathPatterns("/**") //设置所要拦截的路径
                .excludePathPatterns(releasePath);//设置需要放行的路径*/
    }

}
